#include <bits/stdc++.h>
using namespace std;
using LL = long long;

// #define zerol


#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


const int N = 1e2+50;

char s[N][N];

int n;

char pre[N][N];
char tail[N][N];
int ps[N], pt[N];

int len[N];

bool maxpre(char res[]) {
	strcpy(res, pre[0]);
	int la = ps[0];
	for (int i=1; i<n; ++i) {
		int lb = ps[i];
		char *a = res, *b = pre[i];
		bool flag = false;
		if (lb > la) {
			flag = true;
			swap(a, b);
			swap(la, lb);
		}

		for (int j=0; j<lb; ++j) {
			if (a[j] != b[j])
				return false;
		}
		if (flag)
			strcpy(res, a);
	}
	return true;
}

bool maxtail(char res[]) {
	strcpy(res, tail[0]);
	int la = len[0] - pt[0] - 1;
	for (int i=1; i<n; ++i) {
		int lb = len[i] - pt[i] - 1;
		char *a = res, *b = tail[i];
		bool flag = false;
		if (lb > la) {
			flag = true;
			swap(a, b);
			swap(la, lb);
		}
		// printf("%s %s\n", a, b);
		for (int j=0; j<lb; ++j) {
			if (a[la-j-1] != b[lb-j-1]) {
				return false;
			}
		}
		if (flag)
			strcpy(res, a);
	}
	return true;
}

char ansp[N*N], anst[N*N], ans[N*N];

int main() {
	int t;
	scanf("%d", &t);
	for (int kk=0; kk<t; ++kk) {
		scanf("%d", &n);
		for (int i=0; i<n; ++i) {
			scanf("%s", s[i]);
			len[i] = strlen(s[i]);
		}
		for (int i=0; i<n; ++i) {
			for (int j=0; j<len[i]; ++j) {
				if (s[i][j] == '*') {
					dbg(i, j);
					ps[i] = j;
					memcpy(pre[i], s[i], j);
					pre[i][j] = 0;
					break;
				}
			}
			for (int j=len[i]-1; j>=0; --j) {
				if (s[i][j] == '*') {
					dbg(i, j);
					pt[i] = j;
					memcpy(tail[i], s[i]+j+1, len[i]-j-1);
					tail[i][len[i]-j-1] = 0;
					break;
				}
			}
		}
		printf("Case #%d: ", kk+1);

		bool suc1 = maxpre(ansp), suc2 = maxtail(anst);
		dbg(suc1, suc2);
		if (suc1 && suc2) {
			printf("%s", ansp);
			for (int i=0; i<n; ++i) {
				for (int j=ps[i]+1; j<pt[i]; ++j) {
					if (s[i][j] == '*')
						continue;
					putchar(s[i][j]);
				}
			}
			printf("%s\n", anst);
		} else {
			puts("*");
		}
	}

    return 0;
}